home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / crcfast.com / CRCFAST.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-03-25  |  1.3 KB  |  45 lines

  1. ; Assembler interface to Turbo Pascal - CRC Unit
  2. ;
  3. ; Copyright 1988 by Mark R. Boler  -  All Rights Reserved
  4.  
  5. TITLE    CRC
  6.  
  7. DATA     SEGMENT WORD PUBLIC
  8.  
  9.          ASSUME  DS:DATA
  10.  
  11.          EXTRN   CrcTable: WORD
  12.  
  13. DATA     ENDS
  14.  
  15. CODE     SEGMENT BYTE PUBLIC
  16.  
  17.          ASSUME  CS:CODE
  18.  
  19.          PUBLIC  CalcCrc
  20.  
  21. ; PROCEDURE CalcCrc(b: BYTE; VAR TheCrc: WORD); EXTERNAL;
  22.  
  23. TheByte  EQU     BYTE  PTR ss:[bx + 8]
  24. TheCRC   EQU     DWORD PTR ss:[bx + 4]
  25.  
  26. ; WARNING: This procedure must not destroy: ss, sp, ds, bp, cx or si
  27.  
  28. CalcCrc  PROC    FAR
  29.          mov     bx, sp                 ; set up stack frame in bx
  30.          les     di, TheCRC             ; get address of the crc value
  31.          mov     bl, TheByte            ; get the byte into bl
  32.          mov     dx, es:[di]            ; get the value into dx
  33.          xor     bl, dh                 ; bl = array index = dh XOR TheByte
  34.          xor     bh, bh                 ; clear out bh
  35.          shl     bx, 1                  ; multiply by 2 for array index address
  36.          mov     ax, CrcTable[bx]       ; get the crc table value
  37.          xor     ah, dl                 ; calculate the crc value
  38.          mov     es:[di], ax            ; store the value
  39.          ret     6                      ; clean up and return to caller
  40. CalcCrc  ENDP
  41.  
  42. CODE     ENDS
  43.  
  44.          END
  45.